package com.ruoyi.discuss.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.discuss.domain.Bigreply;
import com.ruoyi.discuss.service.IBigreplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回复Controller
 *
 * @author ruoyi
 * @date 2023-12-14
 */
@RestController
@RequestMapping("/discuss/bigreply")
public class BigreplyController extends BaseController
{
    @Autowired
    private IBigreplyService bigreplyService;

    /**
     * 查询回复列表
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bigreply bigreply)
    {
        startPage();
        List<Bigreply> list = bigreplyService.selectBigreplyList(bigreply);
        return getDataTable(list);
    }

    /**
     * 导出回复列表
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:export')")
    @Log(title = "回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bigreply bigreply)
    {
        List<Bigreply> list = bigreplyService.selectBigreplyList(bigreply);
        ExcelUtil<Bigreply> util = new ExcelUtil<Bigreply>(Bigreply.class);
        util.exportExcel(response, list, "回复数据");
    }

    /**
     * 获取回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:query')")
    @GetMapping(value = "/{replyid}")
    public AjaxResult getInfo(@PathVariable("replyid") Long replyid)
    {
        return success(bigreplyService.selectBigreplyByReplyid(replyid));
    }

    /**
     * 新增回复
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:add')")
    @Log(title = "回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bigreply bigreply)
    {
        return toAjax(bigreplyService.insertBigreply(bigreply));
    }

    @PostMapping("/addPoint")
    public AjaxResult addPoint(@RequestBody Bigreply bigreply) {
        return toAjax(bigreplyService.addPoint(bigreply));
    }

    /**
     * 修改回复
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:edit')")
    @Log(title = "回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bigreply bigreply)
    {
        return toAjax(bigreplyService.updateBigreply(bigreply));
    }

    /**
     * 删除回复
     */
    @PreAuthorize("@ss.hasPermi('discuss:bigreply:remove')")
    @Log(title = "回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replyids}")
    public AjaxResult remove(@PathVariable Long[] replyids)
    {
        return toAjax(bigreplyService.deleteBigreplyByReplyids(replyids));
    }


}
